﻿@using GTAuto.DAL.DAL
@model GTAuto.DAL.Entities.GTFirm
@{
    ViewBag.Title = "FirmEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
    List<string> err = ViewBag.Errs;

    int count;
    var cats = DALFirmCategory.Singleton.GetPaged(1, 10000, out count);
    
    
}
<h4 class="alert_info">
    @if (Model.Id > 0)
    {
        <div>
            Редактирование фирмы</div>
    }
    else
    {
  
        <div>
            Создание новой фирмы</div>
    }
</h4>
@using (Html.BeginForm("FirmEdit", "Firms", FormMethod.Post, new { @class = "jNice", enctype = "multipart/form-data" }))
{

    if (err != null && err.Count != 0)
    {

        foreach (var er in err)
        {

    <h4 class="alert_error">
        @er</h4>

        }
    }
    if (ViewBag.Succes != null)
    {
    <h4 class="alert_success">
        @ViewBag.Succes</h4>
    }

    <article class="module width_full">
        <header><h3>Данные о фирме</h3></header>
        <div class="module_content">
            <fieldset>
                <label>Название</label>
                <input type="text" id="Name" name="Name" value="@Model.Name" />
            </fieldset>
            <fieldset>
                <label>Короткое название</label>
                <input type="text" id="ShortName" name="ShortName" value="@Model.ShortName" />
            </fieldset>
            
            <fieldset>
                <label>Основной эл.ящик</label>
                <input type="text" id="Email" name="Email" value="@Model.Email" />
            </fieldset>
            
            
            <fieldset>
                <label>Основной тел. номер</label>
                <input type="text" id="Phone" name="Phone" value="@Model.Phone" />
            </fieldset>
            
            
            <fieldset>
                <label>Основной сайт</label>
                <input type="text" id="SiteUrl" name="SiteUrl" value="@Model.SiteUrl" />
            </fieldset>
            

            <fieldset style="width: 100%; float: left; margin-right: 3%;">
                <label>
                    Аткивная :</label>@Html.CheckBox("Active", Model.Active)
            </fieldset>
            <fieldset style="width: 100%; float: left; margin-right: 3%;">
                <label>
                    Лого(круп.) :</label><input type="file"  id="Logo" name="Logo" value="@Model.Logo" />
            </fieldset>
           
            @if (!string.IsNullOrEmpty(Model.Logo))
            {
                <p>
                    <img src="@string.Format("{0}/{1}", DALSettngs.Singleton.Get("BrendLogosAdminView").Value, Model.Logo)"/>
                </p>
            }
            
            
            <fieldset>
                <label>Описание</label>
                <textarea rows="20" cols="1" name="Description" id="Description">@Model.Description</textarea>
            </fieldset>

            <div class="clear"></div>
        </div>
     
    </article>
    
    <div class="spacer">
    </div>
          
            /// var props = DALModificationProperty.Singleton.GetByCategory(cat.Id);

    <article class="module width_full">
            <header><h3 class="tabs_involved">Принадлежность к категориям</h3>
            </header>
            <table class="tablesorter" cellSpacing="0">
                <tbody> 
              
                @foreach (var cat in cats)
                {
                         <tr>
                        <td style="width:400px;">@cat.Name
                        </td>
                             <td>
                                    <span> @Html.CheckBox("Category_" + cat.Id, DALFirms.Singleton.IsInCategory(Model.Id, cat.Id)) </span>
                               
                             </td> 
                    </tr>
                }
                </tbody>
            </table>
           <footer>
            <div class="submit_link">
               
                <input type="submit" value="Сохранить" class="alt_btn">
               
            </div>
        </footer>
        </article>
            

   

}
@using (Html.BeginForm("AdressEdit", "Firms", FormMethod.Get, new { @class = "jNice", enctype = "multipart/form-data" }))
{
    if (Model.Id > 0)
    {
        var adresses = DALFirmAdress.Singleton.GetPaged(Model.Id, 1, 1000, out count);
    <article class="module width_full">
             <header><h3 class="tabs_involved">Адреса фирмы </h3>
             </header>
              <table class="tablesorter" cellSpacing="0">
                <tbody> 
              
                @foreach (var cat in adresses)
                {
                         <tr>
                        <td style="width:400px;">@cat.Adress
                        </td>
                            <td><a href=@Url.Content("~/Firms/AdressEdit/" + cat.Id) class="edit">Ред.</a></td> 
                            <td><a href=@Url.Content("~/Firms/DeleteAdreses/" + cat.Id) class="delete" onclick="if (!confirm('Вы уверены ?')) return  false;" >Удалить</a></td> 
                    </tr>
                }
                </tbody>
            </table>
             <footer>
                 <div class="submit_link">
               
                     <input type="submit" value="Добавить новый адрес " class="alt_btn">
               
                 </div>
             </footer>
         </article>

    }
}
<!-- end of post new article -->
<div class="spacer">
</div>
